<template>
	<view>
		<uni-popup ref="UniPopup" type="center" @touchmove.stop.prevent="moveHandle">
			<view class="popup" :style="{width:width+'rpx' , color: textColor}">
				<view class=" " style="text-align: center;" :style="{fontSize: fontSize +'rpx' }">
					<text>{{title}}</text>
				</view>
				<view class="content" v-if="type === 'input'">
					<uni-easyinput v-model="inputValue" :placeholder="placeholder" :type="inputType"  placeholder-style="font-size:30rpx;"></uni-easyinput>
				</view>
				<view class="button flex jbetween" style="border-top: 1px solid #e9e9e9;">
					<view class="left" style="color: #000;font-size: 30rpx;flex: 5;border-right: 1px solid #e9e9e9;text-align: center;padding: 10px 0 10px 0;" @click="close">{{ cancelText}}</view>
					<view class="right" style="color: blue;font-size: 30rpx;flex:5;text-align: center;padding: 10px 0 10px 0;" @click="submit">{{confirmText}}</view>
				</view>
			</view>
		</uni-popup>

	</view>
</template>

<script>
	export default {
		props: {
			title: { //标题
				type: String,
				default: "收藏名称"
			},
			inputType: { //input輸入框类型
				type: String,
				default: "text"
			},
			placeholder: { //placeholder
				type: String,
				default: "请输入收藏名称"
			},
			placeholderStyle: {
				type: String,
				default: "font-size:30rpx;padding-left:20rpx"
			},
			type: { //显示的内容区域累心
				type: String,
				default: 'input'
			},
			width: { //彈窗的寬度
				type: [Number, String],
				default: 600
			},
			textColor: { //标题颜色
				type: String,
			},
			fontSize: { //标题字体大小
				type: [Number, String],
				default: 30
			},
			cancelText: { //取消按钮
				type: String,
				default: "取消"
			},
			confirmText: { //确定按钮
				type: String,
				default: "确定"
			},
			parentObj: { //父组件对象
				type: Object
			}
		},
		data() {
			return {
				inputValue:"11",
				childrenObj:{}
			}
		},
		methods: {
			InputClick(event) {
				const inputRule = /[^\d.]/g //只能输入数字和小数
				this.$nextTick(function() {
					this.searchValue = event.replace(inputRule, '');
				})
			},
			moveHandle() {},
			// 搜索
			search(e) {
				let arr = []
				this.data.forEach(item => {
					let newStr = item.NickName + item.Name + item.Phone
					item.newStr = newStr
					console.log('循环', item, item.NickName, item.Name, item.Phone, '-----    ' + item.newStr)
					if (item.newStr.indexOf(e.value) != -1) {
						arr.push(item)
					}
				})
				this.hobby = arr
			},
			open(entity) {
				this.inputValue = entity //清空搜索框
				this.$refs.UniPopup.open() //打开弹窗
			},
			close() {
				this.$refs.UniPopup.close()
			},
			submit() {
				this.$emit('submit', this.inputValue)
				this.$refs.UniPopup.close()
			},

		}
	}
</script>

<style scoped lang="scss">
	.popup {
		background: #fff;
		padding: 20rpx 0rpx 0rpx 0rpx;
		border-radius: 10rpx;
		.content{
			margin: 30rpx 20rpx;
			.input{
				border: 1px solid #ccc;
				border-radius: 10rpx;
				padding: 10rpx 20rpx;
				font-size:30rpx;
				
			}
		}
		.button{
			margin-top: 40rpx;
		}
	}
</style>